//
//  SWTodayMusicsFetchReq.swift
//  ChildStory
//
//  Created by linhan on 2016/12/9.
//  Copyright © 2016年 Aiya. All rights reserved.
//

import Foundation
class SWTodayMusicsFetchReq: SWBaseRequest
{
    override init()
    {
        super.init()
        api = SWRequestAPI.MusicsFetch
        options.authorize = false
        options.resultCodeCheck = false
    }
    
    override func JSONToModel(_ json:JSON, JSONString:String, JSONData:Data) -> AnyObject?
    {
        return Mapper<SWTodayMusicsFetchRsp>().map(JSONString: JSONString)
    }
    
    override func load()
    {
        DispatchQueue.global(qos: .default).async {
            if let url = Bundle.main.url(forResource: "today_musics", withExtension: "json"),
                let data = try? Data(contentsOf: url)
            {
                self.didFinishLoading(data, cache: true)
            }
        }
    }
}

class SWTodayMusicsFetchRsp: NSObject,Mappable
{
    var musics:[SWMusicRsp]?
    var code:Int?
    required init?(map: Map) { }
    
    // Mappable
    func mapping(map: Map) {
        code        <- map["code"]
        musics      <- map["data"]
    }
}
